﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using EHTSaleManager.Code.BLL;
using EHTSaleManager.Code.Entity;
using EHTSaleManager.Code.Utility;

namespace EHTSaleManager.UIAdmin
{
    public partial class AdminProductComfirmDelete : System.Web.UI.Page
    {
        public Int32 ProductID = -1;

        protected void Page_Load(object sender, EventArgs e)
        {            
                try
                {
                    ProductID = Int32.Parse(Request.QueryString["ProductID"].ToString());
                }
                catch (Exception ex)
                {
                    ProductID = -1;
                }          

            if (ProductID != -1)
            {
                ViewState["action"] = HangSo.ACTION_ADD;
                Product theProduct = ProductProvider.GetProductsByProductID(ProductID);
                this.ltrMessage.Text = "Er du sikker slette produktet : " + theProduct.ProductName;
                ViewState["ID"] = theProduct.ProductID;
            }
        }

        protected void btnDelete_Click(object sender, EventArgs e)
        {
            if (ViewState["ID"] != null)
            {
                ProductID = Int32.Parse(ViewState["ID"].ToString());
                ProductProvider.DeleteProductsByProductID(ProductID);
            }

            Response.Redirect("AdminProducts.aspx");
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            Response.Redirect("AdminProducts.aspx");
        }
    }
}